package padrao2;

import java.util.ArrayList;
import java.util.List;

import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.annotations.XStreamAlias;
import com.thoughtworks.xstream.annotations.XStreamImplicit;

public class XSTreamAnnotTest {

    static class Includes {

        @XStreamImplicit(itemFieldName = "include")
        private List<String> include;

        Includes(List<String> include) {
            this.include = include;
        }
    }

    @XStreamAlias("myConfig")
    static class MyConfig {

        private Includes includes;

        public MyConfig(Includes includes) {
            this.includes = includes;
        }

    }

    public static void main(String args[]) throws Exception {
        XStream stream = new XStream();
        stream.processAnnotations(MyConfig.class);
        ArrayList<String> list = new ArrayList<String>();
        list.add("foo");
        list.add("bar");
        Includes cu = new Includes(list);

        MyConfig msg = new MyConfig(cu);
        System.out.println(stream.toXML(msg));
    }
}